import request from "../utils/request";

export const getAllBlogs = (currentPage, size, id) => {
  return request.connection("get", `/blog/blogs`, {
    currentPage: currentPage,
    size: size,
    id: id,
  });
};

export const searchBlogs = (
  title,
  description,
  content,
  currentPage,
  size,
  id
) => {
  return request.connection("get", `/blog/search`, {
    title: title,
    description: description,
    content: content,
    currentPage: currentPage,
    size: size,
    id: id,
  });
};

export const deleteBlog = (id) => {
  return request.connection("put", `/blog/delete/${id}`);
};

export const addBlog = (data) => {
  return request.connection("post", "/blog/add", data);
};

export const updateBlog = (data) => {
  return request.connection("put", "/blog/update", data);
};

export const findBlog = (id) => {
  return request.connection("get", `/blog/find/${id}`);
};

export const countBlogsByMonth = (id) => {
  return request.connection("get", `/blog/countBlogsByMonth/${id}`);
};

export const countBlogs = (id) => {
  return request.connection("get", `/blog/countBlogs/${id}`);
};

export const openRecommend = (id) => {
  return request.connection("put", `/blog/openRecommend/${id}`);
};

export const closeRecommend = (id) => {
  return request.connection("put", `/blog/closeRecommend/${id}`);
};
